<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>IE缓存问题</title>
    <style>
        #result{
            width: 200px;
            height: 100px;
            border: solid 1px #225588;
        }
    </style>
</head>
<body>
    <button>点击发送请求</button>
    <div id="result"></div>
    <script>
        const btn = document.getElementsByTagName('button')[0];
        const result = document.querySelector('#result');

        btn.addEventListener('click', function () {
            // console.log('test');
            //1. 创建ajax对象
            const xhr = new XMLHttpRequest();
            //2. 初始化请求
            //AJAX解决IE缓存问题：加一个可变化的参数，比如时间戳
            xhr.open('GET','http://127.0.0.1:8000/ie?t='+Date.now());
            //3. 发送请求
            xhr.send();
            //4. 处理数据
            xhr.onreadystatechange = function () {
                //两个判断
                if (xhr.readyState === 4) {
                    if (xhr.status >= 200 && xhr.status < 300) {
                        result.innerHTML = xhr.response;
                        
                    }
                    
                }
                
            }
        })

    </script> 
</body>
</html>